package cn.com.connected.controller;

import cn.com.connected.base.params.JsonResult;
import cn.com.connected.base.params.page.BaseSearchDto;
import cn.com.connected.base.params.page.PageResult;
import cn.com.connected.dto.search.SysMessageSearchDto;
import cn.com.connected.service.SysMessageService;
import cn.com.connected.vo.SysMessageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * 
 * @author sms
 * @email sms@live.com
 * @date 2022-10-22 09:37:51
 */
@Api(tags = "")
@RestController
@Slf4j
public class SysMessageController extends BaseController  {

    @Resource
    private SysMessageService sysMessageService;

    @ApiOperation(value="描述:当前人未读消息数量 ok")
    @RequestMapping(value="/v1/sys-message/unread-count",method= RequestMethod.GET)
    public JsonResult<Long> sysMessageDel() {
            Long count = sysMessageService.unreadCount();
            return new JsonResult<>(count==null?0l:count);
    }

    @ApiOperation(value="描述:删除 ok")
    @RequestMapping(value="/v1/sys-message/{id}",method= RequestMethod.DELETE)
    public void sysMessageDel(@PathVariable("id") String id) {
            sysMessageService.sysMessageDel(id);
    }

    @ApiOperation(value="描述:列表 ok")
    @RequestMapping(value="/v1/sys-messages",method= RequestMethod.POST)
    public PageResult<SysMessageVo> sysMessages(@RequestBody BaseSearchDto<SysMessageSearchDto> searchParams) {
        return sysMessageService.sysMessagePage(searchParams);
    }


}
